package com.lxw.study.structural.proxy.dynamicproxy.proxyfactory;

import com.lxw.study.structural.proxy.dynamicproxy.proxyfactory.advice.MyBeforeAdvice;
import com.lxw.study.structural.proxy.dynamicproxy.proxyfactory.advisor.MyPointcutAdvisor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.aop.framework.ProxyFactory;

@Slf4j
public class Client {
    public static void main(String[] args) {
        ProxyFactory proxyFactory = new ProxyFactory();
        proxyFactory.setTarget(new HelloProxy());
        proxyFactory.addAdvice(new MyBeforeAdvice());
        proxyFactory.addAdvisor(new MyPointcutAdvisor());
        HelloProxy proxy = (HelloProxy) proxyFactory.getProxy();
        log.info(proxy.hello("张三"));
        log.info(proxy.hi("李四"));
    }
}
